package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsGoodsMapper;
import com.qf.pojo.DtsGoods;
import com.qf.service.DtsGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Zwnan
 */
@Service
public class DtsGoodsServiceImpl implements DtsGoodsService {
    @Autowired
    private DtsGoodsMapper dtsGoodsMapper;

    @Override
    public Long selectCount() {


        return dtsGoodsMapper.selectCount(null);
    }

    @Override
    public IPage<DtsGoods> findPage(Integer page, Integer limit, String sort, String order) {

        IPage<DtsGoods> iPage = new Page<>(page,limit);


        return dtsGoodsMapper.selectPage(iPage,new QueryWrapper<DtsGoods>().eq("deleted", false));
    }

    @Override
    public DtsGoods selectById(Integer id) {

        return  dtsGoodsMapper.selectById(id);
    }

    @Override
    public void insert(DtsGoods goods) {
        dtsGoodsMapper.insert(goods);
    }

    @Override
    public String selectCategoryId(Integer id) {

        return dtsGoodsMapper.selectCategoryId(id);
    }

    @Override
    public void delete(DtsGoods dtsGoods) {
        dtsGoods.setDeleted(true);
        dtsGoodsMapper.updateById(dtsGoods);
    }

    @Override
    public void update(DtsGoods goods) {
        dtsGoodsMapper.updateById(goods);
    }

    @Override
    public String selectByGoodsId(Long goodsId) {

        return dtsGoodsMapper.selectByGoodsId(goodsId);
    }

    @Override
    public String selectByGoodsId2(Long goodsId) {
        return dtsGoodsMapper.selectByGoodsId2(goodsId);
    }


}
